package com.gitee.swsk33.consulconfigdemo.api;

import com.gitee.swsk33.consulconfigdemo.property.ConfigProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
@RequestMapping("/api/config")
public class GetConfigAPI {

	@Value("${config.string}")
	private String testString;

	@Autowired
	private ConfigProperty configProperty;

	@GetMapping("/get-string")
	public String getTestStringConfig() {
		return testString;
	}

	@GetMapping("/get-property")
	public ConfigProperty getConfigProperty() {
		return configProperty;
	}

}